#ifndef __FLASH_STICK_TYPES_H__
#define __FLASH_STICK_TYPES_H__

enum ETransactionType
{
	eRandom,
	eSequential
};

enum EIOType
{
	eRead,
	eWrite
};

enum EDeviceType
{
	eLogical,
	ePhysical
};

//struct SRel1 
//{
//	int m_na;
//	int m_nb;
//	int m_nc;
//	int m_nd;
//};

class SRel2
{
public:

	// Default Ct'r
	SRel2(): m_nc(0), m_ne(0), m_nf(0), m_ng(0) {}

	// Assignment Operator
	SRel2 & operator=(const SRel2 & rsRel2) 
	{
		if (this != &rsRel2) 
		{
			m_nc = rsRel2.m_nc;
			m_ne = rsRel2.m_ne;
			m_nf = rsRel2.m_nf;
			m_ng = rsRel2.m_ng;
		}
		return *this;
	}

	// Copy Ct'r
	SRel2(const SRel2& rsRel2)
	{
		m_nc = rsRel2.m_nc;
		m_ne = rsRel2.m_ne;
		m_nf = rsRel2.m_nf;
		m_ng = rsRel2.m_ng;
	}

	// Operator <=
	bool operator<= (const SRel2 & rsRel2)
	{
		return (m_nc <= rsRel2.m_nc);
	}

	// Operator <
	bool operator< (const SRel2 & rsRel2)
	{
		return (m_nc < rsRel2.m_nc);
	}

	// Operator >
	bool operator> (const SRel2 & rsRel2)
	{
		return (m_nc > rsRel2.m_nc);
	}

	// Operator ==
	bool operator== (const SRel2 & rsRel2)
	{
		return (m_nc == rsRel2.m_nc);
	}

	int GetKey()
	{
		return m_nc;
	}

	void Clear()
	{
		m_nc = 0;
		m_ne = 0;
		m_nf = 0;
		m_ng = 0;
	}

	int m_nc;
	int m_ne;
	int m_nf;
	int m_ng;
};


class SRel1
{
public:

	// Default Ct'r
	SRel1(): m_na(0), m_nb(0), m_nc(0), m_nd(0) {}

	// Copy Ct'r
	SRel1(const SRel1& rsRel1)
	{
		m_na = rsRel1.m_na;
		m_nb = rsRel1.m_nb;
		m_nc = rsRel1.m_nc;
		m_nd = rsRel1.m_nd;
	}

	// Assignment Operator
	SRel1 & operator=(const SRel1 & rsRel1) 
	{
		if (this != &rsRel1) 
		{
			m_na = rsRel1.m_na;
			m_nb = rsRel1.m_nb;
			m_nc = rsRel1.m_nc;
			m_nd = rsRel1.m_nd;
		}
		return *this;
	}

	// Operator <=
	bool operator<= (const SRel1 & rsRel1)
	{
		return (m_nc <= rsRel1.m_nc);
	}

	// Operator <
	bool operator< (const SRel1 & rsRel1)
	{
		return (m_nc < rsRel1.m_nc);
	}

	// Operator <
	bool operator> (const SRel1 & rsRel1)
	{
		return (m_nc > rsRel1.m_nc);
	}

	// Operator ==
	bool operator== (const SRel1 & rsRel1)
	{
		return (m_nc == rsRel1.m_nc);
	}

	int GetKey()
	{
		return m_nc;
	}

	void Clear()
	{
		m_na = 0;
		m_nb = 0;
		m_nc = 0;
		m_nd = 0;
	}

	int m_na;
	int m_nb;
	int m_nc;
	int m_nd;
};



class sRelResult
{
public:

	// Default Ct'r
	sRelResult() {}

	// Assignment Operator
	sRelResult & operator=(const sRelResult & rsRel) 
	{
		if (this != &rsRel) 
		{
			m_sRel1 = rsRel.m_sRel1;
			m_sRel2 = rsRel.m_sRel2;
		}
		return *this;
	}

	void CopyRel1(const SRel1 & rsRel1) 
	{
		m_sRel1 = rsRel1;
	}

	void CopyRel2(const SRel2 & rsRel2) 
	{
		m_sRel2 = rsRel2;
	}


	// Copy Ct'r
	sRelResult(sRelResult& rsRel)
	{
		m_sRel1 = rsRel.m_sRel1;
		m_sRel2 = rsRel.m_sRel2;
	}

	SRel1 m_sRel1;
	SRel2 m_sRel2;
};

//struct SRel2 
//{
//	int m_nc;
//	int m_ne;
//	int m_nf;
//	int m_ng;
//};

//struct sRelResult
//{
//	SRel1 m_sRel1;
//	SRel2 m_sRel2;
//};

template <class T> 
struct SSortedBufferInfo
{
	SSortedBufferInfo(): m_pBuffer(NULL), m_nCurrIndex(0),  m_dwOffset(0), m_bIsFinished(false), m_nTotalReadBytes(0), m_nLeftBytesToRead(0) {}
	T*			m_pBuffer;
	int			m_nCurrIndex;
	DWORDLONG	m_dwOffset;
	bool		m_bIsFinished;
	int			m_nTotalReadBytes;
	int			m_nLeftBytesToRead;
	int			m_nBytesCount;
	int			m_nRowsCount;
};

struct SColHashElem
{
	int nElem;
	int nIndex;
	int* pnOffset;
};

enum EChosenRsGroup
{
	eUsedG1,
	eUsedG2,
	eNone
};

enum ESortType
{
	eNoSort,
	eInnerSort,
	eOuterSort,
	eInsertInnerSort,
	eInsertOuterSort
	
};

struct SBucketsMapping
{
	DWORDLONG			m_dwPartOffset;
	SBucketsMapping*	m_pNextPart;
	SBucketsMapping*	m_pCurrPart;

	// Used for the whole list
	int					m_nNumberOfParts;
	// Used for the current bucket
	int					m_nNumOfElems;
	int					m_nBytesCount;

	SBucketsMapping():	m_dwPartOffset(0), m_pNextPart(NULL), m_pCurrPart(NULL), m_nNumberOfParts(0), m_nNumOfElems(0), m_nBytesCount(0){}
	~SBucketsMapping()
	{
		int i = 0;
	}

};


struct SSortedPieceInfo
{
	int					m_nPartIndex;
	int					m_nNumOfElements;
	int					m_nMinKey;
	int					m_nMaxKey;
	int					m_nBytesCount;
	SSortedPieceInfo*	m_pNextPiece;

	SSortedPieceInfo(): 
						m_nPartIndex(0),
						m_nNumOfElements(0),
						m_nMinKey(0),
						m_nMaxKey(0),
						m_pNextPiece(0) {}

};

#endif // __FLASH_STICK_TYPES_H__